package com.howard.modules.base.bean;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("serial")
public class DomainObject implements Serializable {

    private String entityId;

    private Long version;

    private String status;

    private Integer id;

    private String orderColumn;

    private String sortDirection = "2";

    /** 逻辑删除标记 */
    private boolean deleteFlag;

    /** 实体动态属性 */
    private Map<String, String> attributes;

    public Map<String, String> getAttributes() {
        return attributes;
    }

    public void setAttributes(Map<String, String> attributes) {
        this.attributes = attributes;
    }

    public String getAttribute(String key) {
        if (attributes == null) {
            return null;
        }
        return attributes.get(key);
    }

    public void setAttribute(String key, String value) {
        if (attributes == null) {
            attributes = new HashMap<String, String>();
        }
        this.attributes.put(key, value);
    }

    public DomainObject() {

    }

    public DomainObject(String id) {
        this.entityId = id;
    }

    public DomainObject(int id) {
        this.id = id;
    }

    public String getEntityId() {
        return entityId;
    }

    public void setEntityId(String entityId) {
        this.entityId = entityId;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public boolean isDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Boolean deleteFlag) {
        deleteFlag = deleteFlag == null ? false : deleteFlag.booleanValue();
        this.deleteFlag = deleteFlag;
    }

    public String getOrderColumn() {
        return orderColumn;
    }

    public void setOrderColumn(String orderColumn) {
        this.orderColumn = orderColumn;
    }

    public String getSortDirection() {
        if ("2".equals(this.sortDirection)) {
            return "asc";
        } else {
            return "desc";
        }
    }

    public void setSortDirection(String sortDirection) {
        this.sortDirection = sortDirection;
    }

}
